<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div,
        p{
            width: 300px;
            height: 30px;
            line-height: 30px;
            color: #fff;
            background-color: #f36;
        }
    </style>
</head>
<body>
    <button>显示当前系统时间</button>
    <div>某个时间</div>
    <p>1123</p>
    <script>
        // 获取标签
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        btn.onclick=function(){
            div.innerHTML = getDate()
        }
        // 定义一个获取时间函数
        function getDate() {
            var date = new Date();
            var year = date.getFullyear();
            var month = date.getMonth()+1;
            var today = date.getDay();
            var week = date.getDay();
            var weekday = ['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
            console.log(week);
            return"今天是："+year+"年"+month+"月"+today+"日"+weekday[week];
            
        }

    </script>
    
</body>
</html>